package com.bci.pwtz.service.cad;

public class Cad_BaseInfo {

	public static final int Table_count = 27;
	public static int[] Table_fieldcount = new int[27];
	public static final String[][] Table_fields;
	public static final String[] Table_names = { "低压线路", "低压导线", "低压杆塔",
			"低压柱上开关", "低压柱上熔断器", "低压熔丝", "低压柱上电容器", "低压无功补偿装置", "低压柱上避雷器",
			"低压表箱", "低压熔丝箱", "低压剩余电流保护器", "低压电缆段", "低压电缆终端", "低压电缆接头", "低压配电箱",
			"低压电缆分接箱", "低压开关", "低压母线", "低压配电盘", "低压开关柜", "反孤岛装置", "变压器",
			"低压间隔单元", "低压墙支架", "用户接入点", "缺陷清理", "" };

	static {
		Table_fields = new String[][] {
				{ "id", "线路名称", "运行编号", "所属变压器类型", "变压器所属站房_线路名称", "所属变压器名称",
						"所属地市", "运维单位", "维护班组", "设备状态", "投运日期", "线路类型",
						"线路总长度", "架空线路长度", "电缆线路长度", "设备主人", "资产性质", "资产单位",
						"资产编号", "备注", "电压等级", "登记时间", "设备编码", "出线开关", "出线开关类型" },
				{ "id", "设备名称", "所属低压线路名称", "起始杆塔", "终止杆塔", "运维单位", "投运日期",
						"设备状态", "型号", "生产厂家", "导线规格", "导线长度", "安全系数", "备注",
						"电压等级", "登记时间", "设备编码", "照片" },
				{ "id", "杆塔编号", "所属低压线路运维单位", "所属低压线路名称", "所属地市", "运维单位",
						"维护班组", "投运日期", "杆塔性质", "档距", "转角方向", "转角度数", "是否终端",
						"设备状态", "型号", "生产厂家", "出厂日期", "杆塔材质", "横担材质", "杆高",
						"基础形式", "接地电阻", "施工单位", "备注", "电压等级", "登记时间", "设备编码",
						"是否同杆架设", "同杆架设回路数", "经度", "纬度", "并架杆塔号", "照片", "上连设备" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属杆塔", "所属地市", "运维单位",
						"维护班组", "投运日期", "开关作用", "设备状态", "型号", "生产厂家", "出厂编号",
						"出厂日期", "灭弧介质", "操作方式", "接地电阻", "额定电压", "额定电流", "备注",
						"电压等级", "登记时间", "设备编码", "开合状态", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属杆塔", "所属地市", "运维单位",
						"维护班组", "投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期",
						"熔丝规格", "备注", "开合状态", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属熔丝箱", "所属地市", "运维单位",
						"维护班组", "投运日期", "设备状态", "型号", "生产厂家", "出厂日期", "熔丝规格",
						"备注", "登记时间", "设备编码", "电压等级", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属杆塔", "所属地市", "运维单位",
						"维护班组", "投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期",
						"额定电压", "单只容量", "台数", "整组容量", "接地电阻", "备注", "电压等级",
						"登记时间", "设备编码", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路运维单位", "所属低压线路名称", "所属杆塔",
						"所属地市", "运维单位", "维护班组", "投运日期", "设备状态", "型号", "生产厂家",
						"出厂编号", "出厂日期", "额定电压", "额定输出容量", "备注", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属杆塔", "所属地市", "运维单位",
						"维护班组", "投运日期", "设备状态", "型号", "生产厂家", "出厂日期", "出厂编号",
						"接地电阻", "备注", "电压等级", "登记时间", "设备编码", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属地市", "运维单位", "维护班组",
						"投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期", "额定电压",
						"额定电流", "备注", "登记时间", "设备编码", "电压等级", "经度", "纬度",
						"距上连设备", "照片", "上连设备" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属地市", "运维单位", "维护班组",
						"投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期", "额定电压",
						"额定电流", "额定容量", "三相线型号", "中性线型号", "测录仪型号", "备注",
						"登记时间", "设备编码", "电压等级", "所属杆塔", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "所属地市", "运维单位", "维护班组",
						"投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期", "额定电压",
						"额定电流", "整定电流值", "延时秒数", "备注", "登记时间", "设备编码", "电压等级",
						"经度", "纬度", "距上连设备", "照片", "上连设备" },
				{ "id", "设备名称", "所属低压线路名称", "所属地市", "运维单位", "维护班组", "投运日期",
						"设备状态", "型号", "生产厂家", "出厂日期", "长度", "额定电压", "绝缘类型",
						"电缆截面", "额定载流量", "线芯材料", "芯数", "备注", "电压等级", "登记时间",
						"设备编码", "起点电缆终端名称", "起点电缆终端连接设备类型", "起点连接设备",
						"终点电缆终端名称", "终点电缆终端连接设备类型", "终点连接设备", "照片" },
				{ "id", "设备名称", "所属低压线路名称", "所属地市", "运维单位", "维护班组", "安装位置",
						"接头类型", "投运日期", "设备状态", "型号", "生产厂家", "出厂编号", "出厂日期",
						"制作单位", "制作人", "备注", "登记时间", "设备编码", "照片" },
				{ "id", "设备名称", "所属低压线路运维单位", "所属低压线路名称", "所属地市", "运维单位",
						"维护班组", "安装位置", "接头类型", "投运日期", "设备状态", "型号", "生产厂家",
						"出厂编号", "出厂日期", "制作单位", "制作人", "备注", "登记时间", "设备编码",
						"安装地点", "所属低压电缆段名称", "照片" },
				{ "id", "设备名称", "所属地市", "运维单位", "维护班组", "安装位置", "接头类型", "投运日期",
						"运行状态", "型号", "生产厂家", "出厂编号", "出厂日期", "制作单位", "制作人",
						"备注", "经度", "纬度", "距上连设备", "照片", "上连设备" },
				{ "id", "设备名称", "所属地市", "运维单位", "维护班组", "设备类型", "投运日期", "设备状态",
						"设备主人", "资产性质", "资产单位", "型号", "生产厂家", "出厂编号", "出厂日期",
						"额定电压", "额定电流", "备注", "经度", "纬度", "距上连设备", "照片", "上连设备" },
				{ "id", "设备名称", "运行编号", "所属地市", "运维单位", "维护班组", "所属站房", "所属盘柜",
						"投运日期", "运行状态", "设备主人", "型号", "生产厂家", "出厂编号", "出厂日期",
						"额定电压", "额定电流", "灭弧介质", "备注", "登记时间", "设备编码", "开合状态",
						"照片" },
				{ "id", "设备名称", "运行编号", "所属地市", "运维单位", "维护班组", "所属电站", "所属盘柜",
						"投运日期", "设备状态", "设备主人", "型号", "生产厂家", "出厂日期", "出厂编号",
						"长度", "母线材质", "截面规格", "母线载流量", "备注", "登记时间", "设备编码",
						"电压等级", "照片" },
				{ "id", "设备名称", "运行编号", "所属站房", "所属地市", "运维单位", "维护班组", "电压等级",
						"投运日期", "运行状态", "是否代维", "设备主人", "资产性质", "资产单位", "资产编号",
						"型号", "生产厂家", "出厂编号", "出厂日期", "备注", "照片" },
				{ "id", "设备名称", "运行编号", "所属电站", "所属地市", "运维单位", "维护班组", "电压等级",
						"投运日期", "类型", "设备状态", "设备主人", "资产性质", "资产单位", "资产编号",
						"出厂日期", "型号", "生产厂家", "出厂编号", "高度", "宽度", "深度", "是否封底",
						"备注", "照片" },
				{ "id", "装置名称", "所属电站", "所属变压器", "所属地市", "运维单位", "维护班组",
						"投运日期", "设备状态", "设备主人", "资产性质", "资产单位", "型号", "生产厂家",
						"出厂编号", "出厂日期", "备注", "登记时间", "设备编码", "电压等级", "资产编号",
						"照片" },
				{ "id", "设备名称", "运行编号", "所属线路", "所属地市", "运维单位", "维护班组", "电压等级",
						"设备状态", "变压器类型", "使用性质", "投运日期", "是否农网", "是否代维",
						"重要程度", "资产性质", "资产单位", "资产编号", "型号", "生产厂家", "出厂编号",
						"出厂日期", "配变总容量", "接地电阻", "经度", "纬度", "照片", "备注" },
				{ "id", "间隔单元名称", "间隔单元编号", "间隔单元类型", "所属地市", "运维单位", "维护班组",
						"所属站房", "电压等级", "投运日期", "所属调度", "调度单位", "接线方式", "设备状态",
						"设备主人", "备注", "设备编码", "功能位置编码", "登记时间", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "设备状态", "安装位置", "备注", "照片" },
				{ "id", "设备名称", "运行编号", "所属低压线路名称", "设备状态", "接入点位置", "备注", "照片" },
				{ "id", "设备类型", "设备名称", "现场照片", "是否处理", "处理结果", "处理日期",
						"开始处理时间", "结束处理时间", "现场操作人员", "现场负责人", "备注" } };
	}

	public static String CAD_cadtpt_dir = "";
	public static String CAD_draw_line = "line %1$f,%2$f %3$f,%4$f "+"\r\n";
	public static String CAD_draw_rectang = "rectang %1$f,%2$f %3$f,%4$f"+"\r\n";
	public static String CAD_draw_text = "text %1$f,%2$f %3$f 0 %4$s"+"\r\n";
	public static String CAD_draw_text_jd = "text %1$f,%2$f %3$f %4$f,%5$f %6$s"+"\r\n";
	public static String CAD_osmode_set = "osmode 20647"+"\r\n";
	public static String CAD_output_dir = "";
	public static String CAD_setcur_layer = "layer s %1$s "+"\r\n";
	public static String CAD_view_all = "zoom a"+"\r\n";

	// "低压柱上开关", "低压柱上熔断器","低压柱上电容器", "低压无功补偿装置", "低压柱上避雷器", "低压熔丝箱",
	public static final int[] CAD_DYGT_SubDevice = { 3, 4, 6, 7, 8, 10 };
	// public static final String[] otlay = { "表箱", "剩余电流保护器", "配电箱", "分接箱" };
	// //{"低压表箱", "型号"} {"低压剩余电流保护器","维护班组"} {"投运日期"}{"设备主人"}
	// public static final int[][] otsub = { { 9, 9 }, { 11, 6 }, { 15, 7 },{
	// 16, 8 } };

	public static final double fz_yz = 2.0D;
	public static double gps_zb_yz = 10.0D;
	public static final String[] lay_names = { "0", "公变", "专变", "直线杆塔", "耐张杆塔",
			"表箱", "分接箱", "配电箱", "熔丝箱", "剩余电流保护器", "电缆", "导线" };
	public static final String lay_bx = "表箱";
	public static final String lay_dl = "电缆";
	public static final String lay_dlbhq = "剩余电流保护器";
	public static final String lay_dx = "导线";
	public static final String lay_fjx = "分接箱";
	public static final String lay_gb = "公变";
	public static final String lay_jt = "接头";
	public static final String lay_lzgt = "耐张杆塔";
	public static final String lay_pdx = "配电箱";
	public static final String lay_rsx = "熔丝箱";
	public static final String lay_zb = "专变";
	public static final String lay_zxgt = "直线杆塔";
	public static final double line_mov_addof = 1.0D;
	public static final int line_pts_mov_left_right = 1;
	public static final int line_pts_mov_only = 3;
	public static final int line_pts_mov_top_bottom = 2;
	public static final int line_type_bottom = 7;
	public static final int line_type_left = 4;
	public static final int line_type_only = 3;
	public static final int line_type_right = 5;
	public static final int line_type_top = 6;
	public static final double min_dxy = 10.0D;
	public static final double min_jl = 4.5D;

	public static final String[] block_names = { "低压直线杆塔", "低压耐张杆塔", "低压电缆接头",
			"低压柱上变压器", "低压箱式变压器", "低压熔丝箱", "低压剩余电流保护器", "低压配电箱", "低压电缆分接箱",
			"低压表箱", "图例" };
	public static final int BLOCK_TYPE_DYGT_ZXGT = 0; // 直线杆塔
	public static final int BLOCK_TYPE_DYGT_NZGT = 1; // 耐张杆塔
	public static final int BLOCK_TYPE_DYDLJT = 2; // 低压电缆接头
	public static final int BLOCK_TYPE_ZSBYQ = 3; // 柱上变压器
	public static final int BLOCK_TYPE_PDBYQ = 4; // 配电箱式变压器
	public static final int BLOCK_TYPE_DYRSX = 5; // 低压熔丝箱
	public static final int BLOCK_TYPE_DYSYDLBHQ = 6;// 低压剩余电流保护器
	public static final int BLOCK_TYPE_DYPDX = 7; // 低压配电箱
	public static final int BLOCK_TYPE_DYDLFJX = 8; // 低压电缆分接箱
	public static final int BLOCK_TYPE_DYBX = 9; // 低压表箱
	public static final int BLOCK_TYPE_TL = 10; // 图例
	public static final double[][] bas_rect = {
			{ 0.0D, 0.0D, 0.3D, 0.0D },
			{ 0.0D, 0.0D, 0.3D, 0.0D },
			{ 0.0D, 0.0D, -0.625D, -0.325D, 0.625D, 0.325D },
			{ 3.145D, 0.0D, -0.895D, -0.895D, 2.145D, 0.895D },
			{ 3.45D, 0.0D, -1.2D, -1.2D, 2.45D, 1.2D },
			{ 1.2D, 1.2D, 0.0D, 0.0D, 2.8139D, 2.4D },
			{ 1.2D, 1.2D, 0.0D, 0.0D, 2.8139D, 2.4D },
			{ 1.825D, 1.2D, 0.0D, 0.0D, 3.65D, 2.4D },
			{ 1.0615D, 1.2D, 0.0D, 0.0D, 2.123D, 2.4D },
			{ 1.0615D, 1.2D, 0.0D, 0.0D, 2.123D, 2.4D },
			{ 0.0D, 0.0D, 0.0D, 0.0D, 27.178599999999999D, 37.176400000000001D } };;

	public static final int obj_zxgt = 0;
	public static final int obj_lzgt = 1;
	public static final int obj_dljt = 2;
	public static final int obj_zsbyq = 3;
	public static final int obj_xsbyq = 4;
	public static final int obj_rsx = 5;
	public static final int obj_dlbhq = 6;
	public static final int obj_dypdx = 7;
	public static final int obj_dyfjx = 8;
	public static final int obj_dybx = 9;
	public static final int obj_tl = 10;
	public static final double one_text_hzw = 0.725D;
	public static final double one_text_zbw = 0.96D;
	public static final int rect_bottom = 1;
	public static final int rect_circle = 2;
	public static final int rect_left = 0;
	public static final int rect_line = 1;
	public static final int rect_point = 0;
	public static final int rect_rectang = 3;
	public static final int rect_right = 2;
	public static final int rect_top = 3;
	public static final double tl_h = bas_rect[10][5] - bas_rect[10][3];
	public static final Cad_Point tl_text_ofpt = new Cad_Point(15.488D, 2.5D);
	public static final double tl_w = bas_rect[10][4] - bas_rect[10][2];
	public static final double jd_1 = 1.0391268368333E-005D;
	public static final double wd_1 = 8.9991020753335E-006D;

	public static Cad_Size getTextSize(String showName, double db) {
		if (showName == null || showName.length() == 0) {
			return null;
		}
		int i = 0;
		int j = 0;
		for (int k = 0; k < showName.length(); k++) {
			if (showName.charAt(k) > '') {
				j++;
			} else {
				i++;
			}
		}
		Cad_Size localEx_dsize = new Cad_Size();
		localEx_dsize.cx = (db * (0.96D * i + 0.725D * j));
		localEx_dsize.cy = db;
		return localEx_dsize;

		// int i = 0;
		// int j = 0;
		// int k = 0;
		// if (k >= showName.length())
		// {
		// Cad_Size localEx_dsize = new Cad_Size();
		// localEx_dsize.cx = (db * (0.96D * i + 0.725D * j));
		// localEx_dsize.cy = db;
		// return localEx_dsize;
		// }
		// if (showName.charAt(k) > '') {
		// j++;
		// }
		// for (;;)
		// {
		// k++;
		// break;
		// i++;
		// }
		//
	}

	public static boolean getDeviceRect(int blockType, Cad_Rect drawRect, Cad_Point point) {
		boolean result = false;
		Cad_Point pt;

		double[][] bas_rect = {
			{ 0.0D, 0.0D, 0.3D, 0.0D },
			{ 0.0D, 0.0D, 0.3D, 0.0D },
			{ 0.0D, 0.0D, -0.625D, -0.325D, 0.625D, 0.325D },
			{ 3.145D, 0.0D, -0.895D, -0.895D, 2.145D, 0.895D },
			{ 3.45D, 0.0D, -1.2D, -1.2D, 2.45D, 1.2D },
			{ 1.2D, 1.2D, 0.0D, 0.0D, 2.8139D, 2.4D },
			{ 1.2D, 1.2D, 0.0D, 0.0D, 2.8139D, 2.4D },
			{ 1.825D, 1.2D, 0.0D, 0.0D, 3.65D, 2.4D },
			{ 1.0615D, 1.2D, 0.0D, 0.0D, 2.123D, 2.4D },
			{ 1.0615D, 1.2D, 0.0D, 0.0D, 2.123D, 2.4D },
			{ 0.0D, 0.0D, 0.0D, 0.0D, 27.178599999999999D, 37.176400000000001D } };;
		
		if (blockType >= 0 && blockType <= 10) {
			pt = new Cad_Point();
			point.x -= bas_rect[blockType][0];
			point.y -= bas_rect[blockType][1];

			switch (blockType) {
			case BLOCK_TYPE_DYGT_ZXGT:
			case BLOCK_TYPE_DYGT_NZGT:
				drawRect.rectType = 2;
				drawRect.set(point, bas_rect[blockType][2]);
				break;
				
			case BLOCK_TYPE_DYDLJT: // 2 低压电缆接头
			case BLOCK_TYPE_ZSBYQ: // 3 柱上变压器
			case BLOCK_TYPE_PDBYQ: // 4 配电箱式变压器
			case BLOCK_TYPE_DYRSX: // 5 低压熔丝箱
			case BLOCK_TYPE_DYSYDLBHQ: // 低压剩余电流保护器
			case BLOCK_TYPE_DYPDX: // 7 低压配电箱
			case BLOCK_TYPE_DYDLFJX: // 8 低压电缆分接箱
			case BLOCK_TYPE_DYBX: // 9 低压表箱

				drawRect.rectType = 0;
				drawRect.set(bas_rect[blockType][2], bas_rect[blockType][3],
						bas_rect[blockType][4], bas_rect[blockType][5]);
				drawRect.moveof(pt);
				break;

			case BLOCK_TYPE_TL: // 10 图例
				drawRect.rectType = 3;
				drawRect.set(bas_rect[blockType][2], bas_rect[blockType][3],
						bas_rect[blockType][4], bas_rect[blockType][5]);
				drawRect.moveof(pt);
				break;
				
			default:
				break;
			}
			result = true;
		}
		return result;

		// Cad_Point pt;
		// if (blockType >= 0) {
		// bool = false;
		// if (blockType <= 10) {
		// pt = new Cad_Point();
		// point.x -= bas_rect[blockType][0];
		// point.y -= bas_rect[blockType][1];
		// switch (blockType) {
		// }
		// }
		// }
		// for (;;) {
		// bool = true;
		// return bool;
		// rect.rectType = 2;
		// rect.set(point, bas_rect[blockType][2]);
		// continue;
		// rect.rectType = 0;
		// rect.set(bas_rect[blockType][2], bas_rect[blockType][3],
		// bas_rect[blockType][4], bas_rect[blockType][5]);
		// rect.moveof(pt);
		// continue;
		// rect.rectType = 3;
		// rect.set(bas_rect[blockType][2], bas_rect[blockType][3],
		// bas_rect[blockType][4], bas_rect[blockType][5]);
		// rect.moveof(pt);
		// }
	}

	public static final Cad_Point getxy(double x, double y) {
		Cad_Point localEx_dpoint = new Cad_Point();
		localEx_dpoint.x = (x / jd_1);
		localEx_dpoint.y = (y / wd_1);
		
//		localEx_dpoint.x = 6400000*Math.cos(x)*Math.cos(y);
//		localEx_dpoint.y = 6400000*Math.cos(x)*Math.sin(y);
		
		return localEx_dpoint;
	}

	public static final Cad_Point getxy(Cad_Point point) {
		if (point != null) {
			return getxy(point.x, point.y);
		}
		return null;
	}

	public static final Cad_Point getxy(String longitude, String latitude) {
		if ((longitude != null) && (latitude != null) && !longitude.trim().equals("") && !latitude.trim().equals("")) {
			return getxy(Double.valueOf(longitude).doubleValue(), Double
					.valueOf(latitude).doubleValue());
		}
		return null;
	}

	public static boolean double_equals(double db1, double db2) {
		return Math.abs(db1 - db2) < 1.E-009D;
	}

}